//
//  WKUser.swift
//  WKWeibo
//
//  Created by 恋guang年 on 16/3/29.
//  Copyright © 2016年 恋guang年. All rights reserved.
//

import UIKit

class WKUser: NSObject {
    /// 用户UID
    var id: Int64 = 0
    
    /// 用户头像地址（中图），50×50像素
    var profile_image_url: String?
    
    /// 用户昵称
    var screen_name: String?
    
    /// 会员等级 1-6
    var mbrank: Int = 0{
        didSet{
            if mbrank > 0 && mbrank <= 6 {
                mbrankImage = UIImage(named: "common_icon_membership_level\(mbrank)")
            } else {    // 防止cell复用,没有会员的就不要等级
                mbrankImage = nil
            }
        }
    }
    /// 会员等级对应的图片
    var mbrankImage: UIImage?
    
    /// verified_type 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_type: Int = -1{
        //字典转模型的为verified_type赋值的时候 为verifiedTvpeImage 这样直接为外界提供认证图片 不用外界View判断类型 模型的职责就是为外界提供数据的
        didSet{
            
            switch verified_type {
            case 0:
                verifiedTvpeImage = UIImage(named: "avatar_vip")
            case 2,3,5:
                verifiedTvpeImage = UIImage(named: "avatar_enterprise_vip")
            case 220:
                verifiedTvpeImage = UIImage(named: "avatar_grassroot")
            default:
                verifiedTvpeImage = nil
            }
        }
    }
    /// 认证类型对应的图片
    var verifiedTvpeImage: UIImage?
    
    ///  字典转模型
    init(dict:[String:AnyObject]){
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    ///  字典中的key在模型中没有找到对应属性
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    ///  对象输出
    override var description: String {
        let keys = ["id","profile_image_url","screen_name","mbrank","verified_type"]
        return "\n\t: \(dictionaryWithValuesForKeys(keys).description)"
    }
}
